package com.skeeey.aim.service.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.skeeey.aim.model.User;
import com.skeeey.aim.service.dao.UserDao;

@SuppressWarnings("unchecked")
public class UserDaoImpl extends TempleteDaoImpl<User, String> implements UserDao {

	@Override
	public User getUserByAccount(String name) {
		User user = null;
		DetachedCriteria criteria = DetachedCriteria.forClass(User.class);
		criteria.add(Restrictions.eq("account", name));
		List<User> users = this.getHibernateTemplate().findByCriteria(criteria);
		if(users.size() > 0) {
			user = users.get(0);
		}
		return user;
	}

}
